package com.wk.paradise.main.config.welcome;

import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @Classname WelcomeView
 * @Description
 * 设置spring boot的默认页，extends WebMvcConfigurerAdapter
 * 重写addViewControllers
 * @Date 2019/12/26 12:14
 * @Author by weikai
 */

@Configuration
public class WelcomeView extends WebMvcConfigurerAdapter {

  @Override
  public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("forward:/index.html");
    /*
    setOrder可以设置ViewController的优先级，强烈建议此处设置为最高，
    这样即使其他Controller中存在一样的映射（即/)，则仍会优先【步骤2】中ViewController。
     */
    registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
    super.addViewControllers(registry);
  }
}
